#include <iostream>
#include "ros/ros.h"
#include "demo_msg/Student.h"
#include "demo_msg/Team.h"

using namespace std;

void callback(const demo_msg::Team::ConstPtr &message) {
  // cout << message->name << endl;
  // cout << message->age << endl;
  // cout << "-----------------------" << endl;

  cout << message->name << endl;
  cout << message->leader.name << endl;
  cout << message->leader.age << endl;
  cout << message->intro.data << endl;

  cout << message->location.linear.x << endl;
  cout << message->location.linear.y << endl;
  cout << message->location.linear.z << endl;
  cout << message->location.angular.x << endl;
  cout << message->location.angular.y << endl;
  cout << message->location.angular.z << endl;

  for (auto member : message->members) {
    cout << member.name << endl;
    cout << member.age << endl;
    cout << "##" << endl;
  }

  cout << "-----------------------" << endl;
}

int main(int argc, char **argv) {
  // 创建节点
  string nodeName = "my_subscriber1";
  ros::init(argc, argv, nodeName);
  ros::NodeHandle node;

  //创建订阅者
  string topicName = "my_topic";
  const ros::Subscriber &subscriber = node.subscribe(topicName, 1000, callback);

  ros::spin();
  return 0;
}